<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>内存监控</title>
    <script src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
    <script src="http://cdn.hcharts.cn/highstock/highstock.js"></script>
    <script src="http://cdn.hcharts.cn/highcharts/modules/exporting.js"></script>
</head>
<body>

<div id="container" style="min-width:400px;height:400px"></div>

</body>

<script type="text/javascript">

$(function () {
    $.getJSON('/data', function (data) {
        // Create the chart
        $('#container').highcharts('StockChart', {
            chart: {
                events: {
                    load: function () {
                        var chart = $('#container').highcharts();
                        var series = chart.series[0];
                        //隔1秒，请求一次/data，实时获取内存信息
                        setInterval(function () {                  
                            $.getJSON("/data", function (res) {
                                $.each(res, function (i, v) {
                                    series.addPoint(v);
                                });
                            });
                        }, 1000);
                    }
                }
            },
            rangeSelector : {
                selected : 1
            },
            title : {
                text : 'AAPL Stock Price'
            },
            series : [{
                name : 'AAPL',
                data : data,
                tooltip: {
                    valueDecimals: 2
                }
            }]
        });
    });
});

</script>
</html>
